<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
use App\User;
class Cart extends Model
{
    use SoftDeletes;
    protected $casts = [
        'attachment' => 'json',
    ];

    public static $status = [ 1 => '已通过', 0 => '待审核'];
    public function getContentAttribute($value)
    {
        return htmlspecialchars_decode($value);
    }
    public function buys()
    {
        return $this->hasOne(Buy::class, 'item_id', 'id');
    }
	public function buysOwn()
    {
        return $this->hasOne(Buy::class, 'item_id', 'id')->where('user_id', Auth::id());
    }
    public function hasUser()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

}
